import Vue from 'vue'
import Router from 'vue-router'
//测试
import home from './views/home.vue'
import index from './views/common/index.vue'
import store from './store.js'
import vueext from './extended/vueext'

Vue.use(vueext);
Vue.use(Router);
//登陆
import login from './views/login.vue' //登陆
import resetPWD from './views/common/resetPWD' //密码修改

//县级填报
import CompanyInfo from './views/Area/dataReport/CompanyInfo'
//桑园面积统计表
import MulAreaStatist from './views/Area/dataReport/MulAreaStatist'
import MulQuartProduc from './views/Area/dataReport/MulQuartProduc'
import MulAnnualProducStatist from './views/Area/dataReport/MulAnnualProducStatist'
import MulAnnualRear from './views/Area/dataReport/MulAnnualRear'
import MulEggsProducStatist from './views/Area/dataReport/MulEggsProducStatist'
import MulComplexQuest from './views/Area/dataReport/MulComplexQuest'
import MulInterCrops from './views/Area/dataReport/MulInterCrops'
import MulSerEarnSurvey from './views/Area/dataReport/MulSerEarnSurvey'
import MulCropIncome from './views/Area/dataReport/MulCropIncome'
import MulProdInfoChart from './views/Area/dataReport/MulProdInfoChart.vue' //生产信息调查统计表

import MulSilkCompany from './views/Area/dataReport/MulSilkCompany'
import MulSilkwormField from './views/Area/dataReport/MulSilkwormField.vue' //生产信息调查统计表

//州（市）审核
import CompanyInfoREV from './views/City/review/CompanyInfo'
import MulAreaStatistREV from './views/City/review/MulAreaStatist'
import MulQuartProducREV from './views/City/review/MulQuartProduc'
import MulAnnualProducStatistREV from './views/City/review/MulAnnualProducStatist'
import MulAnnualRearREV from './views/City/review/MulAnnualRear'
import MulEggsProducStatistREV from './views/City/review/MulEggsProducStatist'
import MulComplexQuestREV from './views/City/review/MulComplexQuest'
import MulInterCropsREV from './views/City/review/MulInterCrops'
import MulSerEarnSurveyREV from './views/City/review/MulSerEarnSurvey'
import MulCropIncomeREV from './views/City/review/MulCropIncome'
import MulProdInfoChartREV from './views/City/review/MulProdInfoChart.vue' //生产信息调查统计表
import MulSilkCompanyREV from './views/City/review/MulSilkCompany'
import MulSilkwormFieldREV from './views/City/review/MulSilkwormField.vue' //生产信息调查统计表

//填报管理
import ReportCreate from './views/ReportMng/ReportCreate.vue' //填报生成
import ReportSet from './views/ReportMng/ReportSet.vue' //填报设置

//系统设置
import dataDict from './views/system/dataDict.vue' //数据字典
import users from './views/system/users.vue' //系统用户
import logs from './views/system/logs.vue' //系统日志
import area from './views/system/area.vue' //行政区划管理
import role from './views/system/role.vue' //角色管理
import menu from './views/system/menu.vue' //菜单管理
import userinfo from './views/system/userinfo.vue' //用户信息
//数据汇总
import statsMulAreaStatist from './views/stats/MulAreaStatist'
import statsMulQuartProduc from './views/stats/MulQuartProduc'
import statsMulAnnualProducStatist from './views/stats/MulAnnualProducStatist'
import statsMulAnnualRear from './views/stats/MulAnnualRear'
import statsMulEggsProducStatist from './views/stats/MulEggsProducStatist'
import statsMulComplexQuest from './views/stats/MulComplexQuest'
import statsMulInterCrops from './views/stats/MulInterCrops'
import statsMulSerEarnSurvey from './views/stats/MulSerEarnSurvey'
import statsMulCropIncome from './views/stats/MulCropIncome'
import statsMulProdInfoChart from './views/stats/MulProdInfoChart.vue' //生产信息调查统计表
import UserStats from './views/stats/UserStats.vue' //生产信息调查统计表
import statsCompanyInfo from './views/stats/CompanyInfo.vue' //企业信息调查
import statsMulSilkCompany from './views/stats/MulSilkCompany.vue' //茧丝绸企业信息
import statsMulSilkwormField from './views/stats/MulSilkwormField.vue' //蚕种场生产经营情况调查表



const routes = [
    { path: '/', name: '登录', component: login },
    { path: '/login', name: '登录', component: login },
    {
        path: '/home',
        name: '主页',
        component: home,
        children: [
            //系统管理
            { path: '/dataDict', name: '数据字典管理', meta: { icon: 'ios-bookmarks', IconSize: 20, FontSize: 20 }, component: dataDict }, //数据字典
            { path: '/users', name: '用户管理', meta: { icon: 'person-stalker', IconSize: 20, FontSize: 20 }, component: users }, //用户管理
            { path: '/logs', name: '日志管理', meta: { icon: 'clipboard', IconSize: 20, FontSize: 20 }, component: logs }, //日志管理	
            { path: '/menu', name: '菜单管理', meta: { icon: 'android-menu', IconSize: 20, FontSize: 20 }, component: menu }, //菜单管理	
            { path: '/role', name: '角色管理', meta: { icon: 'briefcase', IconSize: 20, FontSize: 20 }, component: role }, //角色管理	
            { path: '/area', name: '行政区划管理', meta: { icon: 'map', IconSize: 20, FontSize: 20 }, component: area }, //行政区划管理
            { path: '/userinfo', name: '个人信息修改', meta: { icon: 'person-stalker', IconSize: 20, FontSize: 20 }, component: userinfo }, //个人信息修改
            //报表管理
            { path: '/ReportMng/ReportCreate', name: '报表生成', meta: { icon: 'social-buffer', IconSize: 20, FontSize: 20 }, component: ReportCreate },
            { path: '/ReportMng/ReportSet', name: '报表设置', meta: { icon: 'settings', IconSize: 20, FontSize: 20 }, component: ReportSet },
            //县级填报

            { path: '/Area/CompanyInfo', name: '企业信息调查', meta: { icon: 'podium', IconSize: 20, FontSize: 20 }, component: CompanyInfo },
            { path: '/Area/MulAreaStatist', name: '桑园面积填报', meta: { icon: 'podium', IconSize: 20, FontSize: 20 }, component: MulAreaStatist },
            { path: '/Area/MulQuartProduc', name: '季度生产情况填报', meta: { icon: 'podium', IconSize: 20, FontSize: 20 }, component: MulQuartProduc },
            { path: '/Area/MulAnnualProducStatist', name: '全年蚕桑生产情况填报', meta: { icon: 'podium', IconSize: 20, FontSize: 20 }, component: MulAnnualProducStatist },
            { path: '/Area/MulAnnualRear', name: '全年饲养蚕品种构成填报', meta: { icon: 'podium', IconSize: 20, FontSize: 20 }, component: MulAnnualRear },
            { path: '/Area/MulEggsProducStatist', name: '全年蚕种生产情况填报', meta: { icon: 'podium', IconSize: 20, FontSize: 20 }, component: MulEggsProducStatist },
            { path: '/Area/MulComplexQuest', name: '蚕桑综合利用情况填报', meta: { icon: 'podium', IconSize: 20, FontSize: 20 }, component: MulComplexQuest },
            { path: '/Area/MulInterCrops', name: '桑园套种农作物情况填报', meta: { icon: 'podium', IconSize: 20, FontSize: 20 }, component: MulInterCrops },
            { path: '/Area/MulSerEarnSurvey', name: '养蚕收益情况填报', meta: { icon: 'podium', IconSize: 20, FontSize: 20 }, component: MulSerEarnSurvey },
            { path: '/Area/MulCropIncome', name: '套种作物收益情况填报', meta: { icon: 'podium', IconSize: 20, FontSize: 20 }, component: MulCropIncome },
            { path: '/Area/MulProdInfoChart', name: '县生产信息调查填报', meta: { icon: 'podium', IconSize: 20, FontSize: 20 }, component: MulProdInfoChart },
            { path: '/Area/MulSilkCompany', name: '蚕丝绸企业信息填报', meta: { icon: 'podium', IconSize: 20, FontSize: 20 }, component: MulSilkCompany },
            { path: '/Area/MulSilkwormField', name: '桑蚕种场生产经营情况调查填报', meta: { icon: 'podium', IconSize: 20, FontSize: 20 }, component: MulSilkwormField },
            //州（市）审核
            { path: '/City/CompanyInfo', name: '桑园面积审核', meta: { icon: 'ios-paper', IconSize: 20, FontSize: 20 }, component: CompanyInfoREV },
            { path: '/City/MulAreaStatist', name: '桑园面积审核', meta: { icon: 'ios-paper', IconSize: 20, FontSize: 20 }, component: MulAreaStatistREV },
            { path: '/City/MulQuartProduc', name: '季度生产情况审核', meta: { icon: 'ios-paper', IconSize: 20, FontSize: 20 }, component: MulQuartProducREV },
            { path: '/City/MulAnnualProducStatist', name: '全年蚕桑生产情况审核', meta: { icon: 'ios-paper', IconSize: 20, FontSize: 20 }, component: MulAnnualProducStatistREV },
            { path: '/City/MulAnnualRear', name: '全年饲养蚕品种构成审核', meta: { icon: 'ios-paper', IconSize: 20, FontSize: 20 }, component: MulAnnualRearREV },
            { path: '/City/MulEggsProducStatist', name: '全年蚕种生产情况审核', meta: { icon: 'ios-paper', IconSize: 20, FontSize: 20 }, component: MulEggsProducStatistREV },
            { path: '/City/MulComplexQuest', name: '蚕桑综合利用情况审核', meta: { icon: 'ios-paper', IconSize: 20, FontSize: 20 }, component: MulComplexQuestREV },
            { path: '/City/MulInterCrops', name: '桑园套种农作物情况审核', meta: { icon: 'ios-paper', IconSize: 20, FontSize: 20 }, component: MulInterCropsREV },
            { path: '/City/MulSerEarnSurvey', name: '养蚕收益情况审核', meta: { icon: 'ios-paper', IconSize: 20, FontSize: 20 }, component: MulSerEarnSurveyREV },
            { path: '/City/MulCropIncome', name: '套种作物收益情况审核', meta: { icon: 'ios-paper', IconSize: 20, FontSize: 20 }, component: MulCropIncomeREV },
            { path: '/City/MulProdInfoChart', name: '县生产信息调查审核', meta: { icon: 'ios-paper', IconSize: 20, FontSize: 20 }, component: MulProdInfoChartREV },
            { path: '/City/MulSilkCompany', name: '蚕丝绸企业信息审核', meta: { icon: 'ios-paper', IconSize: 20, FontSize: 20 }, component: MulSilkCompanyREV },
            { path: '/City/MulSilkwormField', name: '桑蚕种场生产经营情况调查审核', meta: { icon: 'ios-paper', IconSize: 20, FontSize: 20 }, component: MulSilkwormFieldREV },
            //密码修改
            { path: '/home/resetPWD', component: resetPWD },
            { path: '/home/', component: index },
            //数据汇总
            { path: '/stats/MulAreaStatist', name: '桑园面积调查表', meta: { icon: 'podium', IconSize: 20, FontSize: 20 }, component: statsMulAreaStatist },
            { path: '/stats/MulQuartProduc', name: '季度蚕桑生产情况调查表', meta: { icon: 'podium', IconSize: 20, FontSize: 20 }, component: statsMulQuartProduc },
            { path: '/stats/MulAnnualProducStatist', name: '全年蚕桑生产情况调查表', meta: { icon: 'podium', IconSize: 20, FontSize: 20 }, component: statsMulAnnualProducStatist },
            { path: '/stats/MulAnnualRear', name: '全年饲养蚕品种构成调查表', meta: { icon: 'podium', IconSize: 20, FontSize: 20 }, component: statsMulAnnualRear },
            { path: '/stats/MulEggsProducStatist', name: '全年蚕种生产情况调查表', meta: { icon: 'podium', IconSize: 20, FontSize: 20 }, component: statsMulEggsProducStatist },
            { path: '/stats/MulComplexQuest', name: '蚕桑综合利用情况调查表', meta: { icon: 'podium', IconSize: 20, FontSize: 20 }, component: statsMulComplexQuest },
            { path: '/stats/MulInterCrops', name: '桑园套种农作物情况调查表', meta: { icon: 'podium', IconSize: 20, FontSize: 20 }, component: statsMulInterCrops },
            { path: '/stats/MulSerEarnSurvey', name: '养蚕收益情况调查表', meta: { icon: 'podium', IconSize: 20, FontSize: 20 }, component: statsMulSerEarnSurvey },
            { path: '/stats/MulCropIncome', name: '桑园套种作物收益情况调查表', meta: { icon: 'podium', IconSize: 20, FontSize: 20 }, component: statsMulCropIncome },
            { path: '/stats/MulProdInfoChart', name: '蚕桑生产信息调查表', meta: { icon: 'podium', IconSize: 20, FontSize: 20 }, component: statsMulProdInfoChart },
            { path: '/stats/UserStats', name: '人员信息统计', meta: { icon: 'podium', IconSize: 20, FontSize: 20 }, component: UserStats },
            { path: '/stats/CompanyInfo', name: '企业信息调查表', meta: { icon: 'podium', IconSize: 20, FontSize: 20 }, component: statsCompanyInfo },
            { path: '/stats/MulSilkCompany', name: '茧丝绸企业信息', meta: { icon: 'podium', IconSize: 20, FontSize: 20 }, component: statsMulSilkCompany },
            { path: '/stats/MulSilkwormField', name: '蚕种场生产经营情况调查表', meta: { icon: 'podium', IconSize: 20, FontSize: 20 }, component: statsMulSilkwormField },
        ]
    }
];

let router = new Router({
    routes
});
//全局 before 钩子: 进入下一个路由前， 修改 Vuex 中的 breadcrumb 内容
router.beforeEach((to, from, next) => {
    var user = Vue.prototype.GetlocaStorage("CSuserinfo");
    var userActions = Vue.prototype.GetlocaStorage("useractionlist");
    if (to.name !== '登录') {
        if (user !== null) {
            if (to.path !== '/home') {
                var BreadcrumbItem = new Object();
                BreadcrumbItem.RouterName = to.name;
                BreadcrumbItem.RouterUrl = to.path;
                BreadcrumbItem.RouterIcon = to.meta.icon;
                store.dispatch('updateBreadcrumb', BreadcrumbItem);
                //用户操作按钮权限列表数据更新
                var actionInfo = new Object();
                actionInfo.path = to.path;
                actionInfo.account = user.Account;
                actionInfo.list = userActions;
                store.dispatch('setActionList', actionInfo);
            } else {
                store.dispatch('desBreadcrumb');
            }
            next();
        } else {
            next({
                path: '/'
            })
        }
    } else {
        next();
    }
})
export default router;